/*   Copyright 2010 Jonathan Wagner
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.alienos.collide;

import java.util.Set;

import com.alienos.collide.bounds.BoundingVolume;
import com.alienos.collide.event.CollisionListener;

/**
 * 
 * @author tigeba
 * 
 * @param <I>
 */
public interface SpatialManager<I> {

    public enum QueryType {
        Intersection, Containment
    }

    /**
     * Put functions as an add-or-update mechanism for a given id object.
     * 
     * @param id
     * @param pos
     * @param bounds
     */
    void put(I id, Transform transform, BoundingVolume bounds);

    void remove(I id);

    /**
     * Return a set of tracked objects contained in the supplied bounding
     * volume.
     * 
     * @param bounds
     * @return
     */
    Set<I> query(BoundingVolume bounds);

    /**
     * Return a set of tracked objects contained in the supplied bounding
     * volume. Supplied objects in excusions will not be returned
     * 
     * @param bounds
     * @param exclusions
     * @return
     */
    Set<I> query(BoundingVolume bounds, Set<I> exclusions);

    Set<I> query(BoundingVolume bounds, Set<I> exclusions, QueryType queryType);

    Set<I> getManagedObjects();

    /**
     * Query manager for an item with a given id
     * 
     * @param id
     * @return Returns the position of the object with id, or null if it does
     *         not exist
     */
    Transform query(I id);

    /**
     * Register to receive collision updates from this manager
     * 
     * @param cl
     */
    void addCollisionListener(CollisionListener<I> cl);

}
